package com.ttxz.common

import android.app.Activity
import android.app.Application
import android.os.Bundle
import com.ttxz.common.base.utils.AppViewManager

/**
 * Activity生命周期全局监测，用于处理Activity栈
 *
 * @author ttxz
 * @date 2022/6/11 11:03
 */
class MyActivityLifecycleCallbacks : Application.ActivityLifecycleCallbacks {
    override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {
        AppViewManager.addActivity(activity)
    }

    override fun onActivityStarted(activity: Activity) {}
    override fun onActivityResumed(activity: Activity) {}
    override fun onActivityPaused(activity: Activity) {}
    override fun onActivityStopped(activity: Activity) {}
    override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) {}
    override fun onActivityDestroyed(activity: Activity) {
        AppViewManager.removeActivity(activity)
    }
}